function [circuit]=bestStageCircuit (poles, zeros, stageType)
%   Celda            Numero
%   Sallen Key       1
%   Sedra            2
%   Universal        3
%   Rauch            4
%   Integrator       5
%   Derivator        6

% for m=1:length(zeros)
%     if(~(zeros(m)==0))
%         zeros(abs(real(zeros)) > 1e-3) = 1i*imag(zeros(abs(real(zeros)) > 1e-3));
%     end   
% end
if length(zeros)==2
    if abs(2*real(zeros(1)))<abs(zeros(1))
        zeros(1)=-1i*imag(zeros(1));
        zeros(2)=-1i*imag(zeros(2));
    end
end
        
Q=abs(poles(1)/(2*real(poles(1))));

if length(poles)==1
   if stageType==2;
       circuit= 5; %
   elseif stageType==3
       circuit=6; %
   end
else
    if length(zeros)==2 && abs(zeros(1))==abs(imag(zeros(1))) && abs(imag(zeros(1)))~=0
        if stageType==2 || stageType==3
            if Q<=20
                circuit=2; % Sedra
            else circuit=3; % Universal
            end
        end
    elseif stageType==2 || stageType==3
        if Q<=5
            circuit=1 ; % Sallen Key
        elseif Q<=20
            circuit=2 ; % Sedra
        else circuit=3 ; % Universal
        end
    elseif stageType==1
        if Q>=5 && Q<=20
            circuit=4 ; % Rauch
        else circuit=3 ; % Universal
        end
    elseif stageType==4
        circuit=3 ; % Universal
    end
end
end